<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/16
 * Time: 14:20
 */
namespace App\Http\Controllers\web;

use App\Models\V1\BookModel;
use App\Models\V1\MemberModel;
use App\Models\V1\DrpModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Module\EntMemberInfo;
use App\Module\EntMobileCode;
use App\Module\EntMemberDRP;
use App\Module\EntMemberMoney;
use App\Module\EntMoneyRewardLog;
use App\Module\EntAwardMoneyLog;
use App\Module\EntReadingParty;
use Overtrue\Socialite\User;
use Session;
use Redirect, Validator, Cookie, Response, DB, View;
use App\Models\V1\ReadPartyModel;
use App\Http\Controllers\Weixin\WeixinServiceController;
use App\Models\Common\UserRegisterTemplateModel;
use App\Http\Controllers\Service\WeixinBuyVip;



class WebLoginController extends Controller
{
    /*
     * 学习币记录
     * @param id 学习群ID
     * @param mobile 手机号
     * @param key 登录key
     * */
    public function moneylog(Request $request)
    {
        $path   = $request->getPathInfo();

        preg_match('/-[\w-]+-/',$path,$r);
        $key   = trim($r[0],'-');
        preg_match('/\d{5,15}-/',$path,$r);
        $mobile = trim($r[0],'-');
        preg_match('/\d+\./',$path,$r);
        $id = (int) trim($r[0],'.');

        //$member         = $this->memNumber($mobile, $key);
        $memberModel    = new MemberModel();
        $member         = $memberModel->get_member_info_by_mobile($mobile);
        $readPartyModel = new ReadPartyModel();

        if (count($member) == 0) {
            return view('web/weblogin/membermoneylog', ['code'=>0,'message'=>'账户异常，请检查!']);
        }

        //检查是否参加该群
        $exists        = $readPartyModel->check_read_party_member_exists($id,$member->UserID);
        if ($exists == false) {
            return view('web/weblogin/membermoneylog', ['code' => 1, 'message' => '您还没有参加本学习群']);
        }


        /*当前读书会的学习币总量记录  而不是学习币详情的日志记录*/
        $memoney = EntMemberMoney::where('MemNumber', $member->MemNumber)
            ->where('ReaParID', $id)
            ->value('StudyMoney');
        $memoney = $memoney?$memoney:0;

        /*暂时无用  因为每一数据*/
        $entAwardMoneyLog = EntAwardMoneyLog::select('AwMoLoID as id', 'AwMoLoDesc as desc', 'AwMoLoType as type', 'AwMoLoMoney as money', 'AddDate as time')
            ->where('ReaParID', $id)
            ->where('MemNumber', $member->MemNumber)
            ->orderby('AddDate', 'desc')
            ->get();



        /*学习币打赏记录 从数据来讲是减少，即打赏给别人*/
        $colum = [
            'MoReLoID as id',
            'MoReLoDesc as desc',
            'MoReLoType as type',
            'MoReLoMoney as money',
            'AddDate as time'
        ];

        $entMoneyRewardLog = EntMoneyRewardLog::select($colum)
            ->where('MemNumber', $member->MemNumber)
            ->where('read_party_id',$id)
            ->orderby('AddDate', 'desc')
            ->get();


        /*打赏记录   学习币减少*/
        $entBeiMoneyRewardLog = EntMoneyRewardLog::select(
            'MoReLoID as id',
            'MoReLoBeiDesc as desc',
            'MoReLoType as type',
            'MoReLoMoney as money',
            'AddDate as time')
            ->where('BeiMemNumber', $member->MemNumber)
            ->where('read_party_id',$id)
            ->orderby('AddDate', 'desc')->get();

        foreach ($entMoneyRewardLog as $data) {
            $data->type = 0;
        }


        $arrayCollapseMoneyLog  = array_collapse([$entAwardMoneyLog, $entMoneyRewardLog, $entBeiMoneyRewardLog]);
        $collectMoneyCollect    = collect($arrayCollapseMoneyLog);
        $sorted                 = $collectMoneyCollect->sortByDesc('time');
        $str                    = $sorted->values()->all();
        $reaParName             = EntReadingParty::find($id);
        $data = [
            'moneyloglist'  => $str,
            'memoney'       => $memoney,
            'name'          => $reaParName->ReaParName,
            'code'=>'200'
        ];

        return view('web/weblogin/membermoneylog', $data);
    }



    /*
     * 学习官分享或首页进入
     *
     * */
    public function getWebLogin(Request $request,$drpId = 0)
    {
        $unionId    = "";
        $openId     = "";
        $userId     = $request->input('userId',0);
        $bookId     = $request->input('bookId',9);
        if($bookId < 1)
        {
            $bookId = 9;
        }
        $bookModel  = new BookModel();
        $bookInfo   = $bookModel->get_book_info($bookId);
        $weixinServer   = new WeixinServiceController();


        if(is_weixin())
        {
            $userWeixinInfo = $weixinServer->userinfo($request);
            $unionId        = $userWeixinInfo['original']['unionid'];
        }

        //1.获取学习官的名字
        $parentGradeName = false;

        $drpModel   = new DrpModel();
        if($userId > 0)
        {
            $userInfo       = $drpModel->get_member_info_by_id($userId);
            if($userInfo)
            {
                $parentGradeName= $userInfo->YourName ?? $userInfo->NickName;
                $openId         = $userInfo->WeiXID;
            }
            else{

                $userId = 0;
            }

        }elseif($drpId > 0) {

            $drpInfo    = $drpModel->get_drp_info_by_drpid($drpId);
            if($drpInfo)
            {
                $parentGradeName    = $drpInfo->YourName ?? $drpInfo->NickName;
                $userId             = $drpInfo->UserID;
                $openId             = $drpInfo->WeiXID;
            }
        }

        //绑定用户与学习官的关系
        if($unionId && $userId > 0)
        {
            $info   = DB::table('wx_user_and_clo')
                ->where('clo_user_id',$userId)
                ->where('wx_unionid',$unionId)
                ->first();
            if(!$info)
            {
                $info   = [
                    'clo_user_id'   => $userId,
                    'wx_unionid'    => $unionId,
                    'wx_name'       => $userWeixinInfo['name']
                ];


                $noticeInfo = new UserRegisterTemplateModel();
                $noticeInfo->title  = "教导读书会【推广码】扫码通知";
                $noticeInfo->name   = $userWeixinInfo['name'];
                $noticeInfo->mobile = "暂无";
                $noticeInfo->detail = "又一个微信朋友扫码成为你的潜在待开发会员哦！";
                $noticeInfo->openId = $openId;
                if($noticeInfo->openId && $weixinServer->isSubscribe($noticeInfo->openId))
                {
                    $weixinServer->send_user_register_template($noticeInfo);
                }
                DB::table('wx_user_and_clo')->insert($info);
            }

        }

        //判断系统
        $ios    = "https://itunes.apple.com/cn/app/id1187561609?mt=8";
        $android= asset('downloadpage.html');
        $appUrl = is_ios() ? $ios : $android;
        $data   = [
            'parentGradeName'   => $parentGradeName,
            'appUrl'            => $appUrl,
            'bookInfo'          => $bookInfo
        ];
        return view('web/weblogin/weblogin', $data);
    }

    private $vipTypes   = [
        [],
        ['name'=>'vip会员','money'=>690,'id'=>1],
        //['name'=>'vip会员','money'=>0.01,'id'=>1],
        ['name'=>'超级会员','money'=>2000,'id'=>2],
    ];

    /**
     * 会员类型
     * */
    public function vip_type(Request $request)
    {
        return view('/web/weblogin/vip-types');
    }


    /**
     * 购买会员
     * */
    public function buy_vip(Request $request)
    {

        $vipType        = $request->input('vipType');
        $vipType        = $this->vipTypes[$vipType];

        $body   = "教导读书会".$vipType['name'];
        $money  = $vipType['money'];
        $weixinService  = new WeixinServiceController();
        $userInfo       = $weixinService->userinfo($request);
        $openId         = $userInfo['id'];
        $orderNumber    = create_order_number();
        $body           = $body;
        $detail         = "购买教导读书会会员";
        $callbackUrl    = asset("web/weblogin/buy_vip_callback");
        $payConfig      = $weixinService->get_wx_pay_config($openId,$money,$orderNumber,$body,$detail,$callbackUrl);

        $year           = date('Y');
        $time           = date('.m.d');
        $time           = $year.$time ."——".($year+1).$time;

        $data           = [
            'time'          => $time,
            'payConfig'     => $payConfig,
            'orderNumber'   => $orderNumber,
            'money'         => $money,
            'vipType'       => $vipType['id'],
            'userName'      => $userInfo['name'],
            'headImg'       => $userInfo['avatar'],
            'openId'        => $openId
        ];

        return view('/web/weblogin/buy-vip',$data);
    }


    /**
     * 企业会员申请
     * */
    public function buy_company(Request $request)
    {
        if(is_weixin())
        {
            $weixinService  = new WeixinServiceController();
            $weixinInfo     = $weixinService->userinfo($request);
        }
        return view('web/weblogin/buy-company');
    }

    /**
     * 添加购买VIP会员订单
     * */
    public function add_buy_vip_order(Request $request)
    {
        $vipType        = $request->input('vipType');
        $vipType        = $this->vipTypes[$vipType];
        $weixinService  = new WeixinServiceController();
        $userInfo       = $weixinService->userinfo($request);

        $orderNumber    = $request->input('orderNumber');
        $unionId        = $userInfo['original']['unionid'];
        $openId         = $request->input('openId');
        $name           = $request->input('name');
        $userId         = 0;
        $money          = $vipType['money'];

        WeixinBuyVip::add_wx_order("gzh","vip",$vipType['id'],$money,$orderNumber,$unionId,$openId,$name,$userId);

        return apiData()->send(200,'ok');
    }

    /**
     * 购买VIP回调
     * */
    public function buy_vip_callback(Request $request)
    {
        $weixinService      = new WeixinServiceController();
        $app                = $weixinService->get_oauth_client_app();

        $response = $app->payment->handleNotify(function($notify, $successful)
        {
            $tradeNo        = $notify->out_trade_no;    //订单号

            $orderInfo  = DB::table('wx_app_pay_log')->where('trade_no',$tradeNo)->first();

            $endTime    = (date('Y') + 1) . date('-m-d h:i:s');
            $now        = date_time();
            //添加新会员
            $data = [
            "States"    =>1,
            "MemNumber" =>create_member_number(),
            "UserName"  =>"",
            "UserPassWord"=>"",
            "NickName"  =>$orderInfo->wx_name,
            "YourName"  =>$orderInfo->wx_name,
            "FilePath1" =>"",
            "LoginKey"  =>"",
            "WeiXID"    =>$orderInfo->openid,
            "VipNumber" =>"",
            "MemIntegral"=>"",
            "MemEndTime"=>$endTime,
            "personal_end_time"=>$endTime,
            "RegisterType"=>"wxbuy",
            "AppKey"    =>"",
            "DeleteMark"=>1,
            "ReleaseDate"=>$now,
            "AddDate"   =>$now,
            "wx_unionid"=>$orderInfo->unionid,
            "app_openid"=>"",
            "head_img"  =>"",
            "sex"       =>"",
            "city"      =>0,
            "country"   =>0,
            "email"     => ""
            ];

            //检查该微信用户是否存在
            $memberModel    = new MemberModel();
            $memberInfo     = $memberModel->get_member_info_by_unionid($orderInfo->unionid);
            if($memberInfo)
            {
                $userId     = $memberInfo->UserID;
                //结束时间
                if(strtotime($memberInfo->personal_end_time) < time())
                {
                    $endTime    = time();
                }
                else
                {
                    $endTime    = strtotime($memberInfo->personal_end_time);
                }
                $year       = date('Y',$endTime) + 1;
                $endTime    = $year . "-" . date('m-d',$endTime);
                $data       = [
                    'States'            => 1,
                    'personal_end_time' => $endTime,
                    'UserID'            => $userId,
                    'ReleaseDate'       => date_time()
                ];
                $memberModel->update_member_info($data);
                $memberModel->change_member_endtime($userId);

            }else{

                $userId     = DB::table('memberinfo')->insertGetId($data);
            }

            $templateInfo   = new UserRegisterTemplateModel();
            $templateInfo->title    = "微信会员购买通知";
            $templateInfo->mobile   = "未知";
            $templateInfo->name     = $orderInfo->wx_name;
            $templateInfo->openId   = system_log('service-2');
            $templateInfo->detail   = "支付金额".$notify->total_fee / 100;
            $weixinService  = new WeixinServiceController();
            $weixinService->send_user_register_template($templateInfo);


            $updateInfo = [
                'user_id'           => $userId,
                'pay_time'          => $notify->time_end,
                'transaction_id'    => $notify->transaction_id,
                'pay_money'         => $notify->total_fee,
                'openid'            => $notify->openid,
                'pay_status'        => 1
            ];

            DB::table('wx_app_pay_log')
                ->where('id',$orderInfo->id)
                ->update($updateInfo);


            return true; // 或者错误消息
        });


        return $response; // Laravel 里请使用：return $response;
    }



    /**
     * 公司申请
     * */
    public function company_apply(Request $request)
    {

        $time   = date_time();
        $i      = $request;
        $data   = [
            'company_name'      => $i->input('companyName'),
            'employee_number'   => $i->input('employeeNumber'),
            'user_name'         => $i->input('userName'),
            'user_mobile'       => $i->input('userMobile'),
            'user_job'          => $i->input('userJob'),
            'wx_name'           => '',
            'wx_head'           => '',
            'open_id'           => '',
            'created_at'        => $time,
            'updated_at'        => $time
        ];

        $paras  = [
            'company'   => [$data['company_name'],'缺少公司名称',201],
            'employee'  => [$data['employee_number'],'请填写公司人数',202],
            'mobile'    => [$data['user_mobile'],'缺少手机',203],
            'name'      => [$data['user_name'],'缺少姓名',204]
        ];

        $result     = $this->check_params($paras);
        if($result->status == false)
        {
            return apiData()->send($result->code,$result->message);
        }
        $weixinService  = new WeixinServiceController();
        $cloname = "无";

        if(is_weixin())
        {
            $userInfo       = $weixinService->userinfo($request);
            $data['wx_name']= $userInfo['name'];
            $data['wx_head']= $userInfo['avatar'];
            $data['open_id']= $userInfo['id'];

            $wxunionid = $userInfo['original']['unionid'];

            #查找学习官
            $cloInfo = DB::table('wx_user_and_clo')->where('wx_unionid',$wxunionid)->orderBy('id')->first();


            if($cloInfo)
            {
                $cloInfo = DB::table('memberinfo as a')
                    ->leftJoin('memberdrp as b','b.MemNumber','=','a.MemNumber')
                    ->where('a.UserID',$cloInfo->clo_user_id)
                    ->select('a.YourName','b.DRPLevel')
                    ->first();

                if($cloInfo && $cloInfo->DRPLevel == 1)
                {
                    $cloname = $cloInfo->YourName;
                }
            }
        }

        //给客服通知
        $registerTemplate   = new UserRegisterTemplateModel();
        $registerTemplate->name     = $i['companyName'];
        $registerTemplate->mobile   = $i['userMobile'];
        $registerTemplate->title    = '新公司申请企业会员';
        $registerTemplate->detail   = "微信用户[".$i['userName']."]申请企业会员，公司".$i['employeeNumber']."个员工,学习官:[{$cloname}],速联系";
        $registerTemplate->openId   = system_log('chenliang_id');
        $weixinService->send_user_register_template($registerTemplate);

        DB::table('company_apply')->insert($data);
        return apiData()->send(200,'申请成功,客服会及时联系您！');
    }

    public function register(Request $request)
    {
        $id = $request->input('id',0);
        $parentGradeName = false;
        if($id>0){
            if($id=='5175'){
                $id = 507;
            }

            $memberInfo = DB::table('memberdrp')->where('DRPID',$id)->first();
            if(count($memberInfo) > 0){
                $memberNumber = $memberInfo->MemNumber;
                $userInfo = DB::table('memberinfo')->select('YourName','UserName')->where('MemNumber',$memberNumber)->first();
                if($userInfo->YourName){
                    $parentGradeName = $userInfo->YourName;
                }else if($userInfo->UserName){
                    $parentGradeName = $userInfo->UserName;
                }
            }
        }

        $countrys   = DB::table('countrys')
            ->where('is_show',1)
            ->select('country_china_name','country_num_code')
            ->get();

        $data   = [
            'id'                => $id,
            'parentGradeName'   => $parentGradeName,
            'countrys'          => $countrys,
        ];
        return view('/web/weblogin/register',$data);

    }



    public function get_apk_url(){
        $info = DB::table('app_version')
            ->whereNull('deleted_at')
            ->where('is_show',1)
            ->where('client','Android')
            ->orderBy('id','desc')
            ->first();
        $apkUrl = env('HOST')."/".$info->apk_url;
        return $apkUrl;
    }




    //检查用户是否存在
    public function check_user_exists(Request $r){
        $mobile  = $r->get('mobile');
        $count   = DB::table('memberinfo')->where('UserName',$mobile)->where('DeleteMark',1)->count();
        if($count>0){
            return ['error_code'=>0,'info'=>'已存在改号码','number'=>$count];
        }else{
            return ['error_code'=>0,'info'=>'不存在改用户','number'=>0];
        }
    }
    /**
     * 添加会员
     * @param Request $request
     * @return Redirect
     */
    public function loginstore(Request $request)
    {
        $mobile     = trim($request->get('txtMobile'));   //手机号
        $yourName   = trim($request->get('txtYourName')); //用户名
        $parentId   = trim($request->get('hiid'));
        $openId     = $request->session()->get('openId','');
        $country    = $request->get('country');
        if(empty($mobile)){
            return redirect::back()->withInput()->withErrors('请输入手机号！');
        }

        if(empty($yourName)){
            return redirect::back()->withInput()->withErrors('请输入姓名！');
        }

        $memberInfoTwo = $this->checkMemberInfo($mobile);

        if (count($memberInfoTwo) > 0) {
            //您的手机号已注册
            return redirect::back()->withInput()->withErrors('您的手机号已注册,请勿重复注册！');
        }
        $MemNumber = create_member_number();
        //登录key，有什么用呢？
        $loginKey = md5(date('YmdHis', time()));
        DB::beginTransaction();
        try {
            $entMemberInfo = new EntMemberInfo();
            $entMemberInfo->States  = 0;
            $entMemberInfo->MemNumber = $MemNumber;
            $entMemberInfo->UserName = $mobile;
            $entMemberInfo->YourName = $yourName;
            $entMemberInfo->UserPassWord = '';
            $entMemberInfo->NickName = '';
            $entMemberInfo->FilePath1 = '';
            $entMemberInfo->WeiXID = $openId;
            $entMemberInfo->VipNumber = 1;
            $entMemberInfo->MemIntegral = 0;
            $entMemberInfo->LoginKey = $loginKey;
            $entMemberInfo->MemEndTime = '';
            $entMemberInfo->AppKey = '';
     
            $entMemberInfo->RegisterType = 2;
            $entMemberInfo->DeleteMark = 1;
            $entMemberInfo->ReleaseDate = date('Y-m-d H:i:s', time());
            $entMemberInfo->AddDate = date('Y-m-d H:i:s', time());
            $entMemberInfo->country = $country;
            $entMemberInfo->save();
            //如果是扫描的二维码进来，会有父ID
            if ($parentId > 1) {
                $ParentID = $parentId;
                $entMemberDRP = new EntMemberDRP();
                $entMemberDRP->MemNumber = $entMemberInfo->MemNumber;
                $entMemberDRP->SalesMoney = 0;
                $entMemberDRP->MemBalances = 0;
                $entMemberDRP->FinishMoney = 0;
                $entMemberDRP->DRPScale = '';
                $entMemberDRP->DRPLevel = 2;
                $entMemberDRP->IDTree = '.' . $ParentID . '.';
                $entMemberDRP->ParentID = $ParentID;
                $entMemberDRP->MasterID = 0;
                $entMemberDRP->DeleteMark = 1;
                $entMemberDRP->ReleaseDate = date('Y-m-d H:i:s', time());
                $entMemberDRP->AddDate = date('Y-m-d H:i:s', time());
                $entMemberDRP->save();
                //修改DOP状态
                DB::table('MemberDRP')->where('DRPID', $entMemberDRP->DRPID)->update(['IDTree' => $entMemberDRP->IDTree . $entMemberDRP->DRPID . '.']);
            }
            DB::commit();
            $url = "/downloadpage.html";
            return redirect($url);
        } catch (Exception $e) {
            DB::rollBack();
        }
    }



    // 获取手机验证码
    public function addMobCode(Request $request)
    {
        try {
            $usermobile = $request->get('mobile');
            $usermobile = $usermobile?$usermobile:$request->json('mobile');
            $reg = '/^1[0-9]{10}$/';
            if(!preg_match($reg,$usermobile)){
                return ['error_code'=>1,'error_msg'=>"手机号格式错误"];
            }

            $entMobileCodeTime = EntMobileCode::select('EndTime', 'ID')->where('Mobile', $usermobile)
                ->where('States', 1)
                ->orderBy('AddDate', 'desc')
                ->first();

            if (count($entMobileCodeTime) > 0) {
                $nowtime = date('Y-m-d H:i:s', time());
                $endtime = $entMobileCodeTime->EndTime;
                if (strtotime($nowtime) < strtotime($endtime)) {
                    // 时间没有到
                    return ['error_code'=>1,'error_msg'=>'验证码已发送，请等待'];
                }
            }

            $Code = $this->RandStr(5);
            $now = date('Y-m-d h:i:s', time());
            $entMobileCode = new EntMobileCode();
            $entMobileCode->States = 1;
            $entMobileCode->Mobile = $usermobile;
            $entMobileCode->Code = $Code;
            $entMobileCode->EndTime = date("Y-m-d H:i:s", strtotime("+2minutes", strtotime($now)));
            $entMobileCode->AddDate = date('Y-m-d H:i:s', time());
            $entMobileCode->save();

            $coment = $this->getMobileCode($usermobile, $Code);
            //$coment = "ok;0000";
            DB::table('mobilecode')->where('ID', $entMobileCode->ID)->update(['msg' => $coment]);
            $k = explode(';', $coment);
            $g = $k[0];
            if (strtolower($g) == 'ok') {   // 发送成功！
                return ['error_code'=>0,'error_msg'=>'发送成功'];
            } else {
                return ['error_code'=>1,'error_msg'=>'发送失败,请联系客服'];
            }
        } catch (Exception $e) {
            return ['error_code'=>1,'error_msg'=>'系统异常'];
        }
    }



    // 验证手机验证码
    public function checkMobCode(Request $request)
    {
        $result = '';
        try {
            if ($request->ajax()) {
                $userimgcode = '';
                $usermobcode = $request->get('mobcode');
                $usermobile = $request->get('mobile');
                if ($usermobcode == '666666') {
                    $result = '3';
                } else {
                    $mobileCode = EntMobileCode::select('ID')->where('Mobile', $usermobile)
                        ->where('States', 1)
                        ->where('Code', $usermobcode)
                        ->first();
                    if (count($mobileCode) > 0) {
                        $delMobileCode = EntMobileCode::where('Mobile', $usermobile)->where('States', 1)
                            ->delete();
                        $result = '3';
                    } else {
                        // 您输入的手机验证码不正确
                        $result = '2';
                    }
                }

            }
        } catch (Exception $e) {
            $result = '4';
        }
        return $result;
    }


    //随机数字
    protected function RandStr($n)
    {
        $s = '';
        $str = "012356789"; // 输出字符集
        $len = strlen($str) - 1;
        for ($i = 0; $i < $n; $i++) {
            $s .= $str[rand(0, $len)];
        }
        return $s;
    }

    protected function getMobileCode($mobile = '', $code = '')
    {


        $msg = '感谢您注册老侯代读！您本次的注册验证码为:' . $code . '。请及时验证注册！';
        $url = 'http://103.47.139.8/SHHL95/qxtinterface.aspx?phone=' . $mobile . '&message=' . iconv("UTF-8", "gb2312", $msg) . '&user=nanguash&pwd=laohou123';
        if (ini_get("allow_url_fopen") == "1") {
            $response = file_get_contents($url);
        } else {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_URL, $url);
            $response = curl_exec($ch);
            curl_close($ch);
        }

        // -------请求为空
        if (empty($response)) {
            $this->error->showError("50001");
        }
        return $response;
    }

    protected function checkMemberInfo($name)
    {
        $entMemberInfo = EntMemberInfo::select('MemNumber', 'UserName', 'States', 'MemEndTime', 'WeiXID')->where('DeleteMark', '1')->where('UserName', $name)->first();
        return $entMemberInfo;
    }

    /**
     * 返回会员标示
     * @param string $mobile
     * @param string $appkey
     * @return mixed
     */
    protected function memNumber($mobile = '', $appkey = '')
    {
        $entBookInfo = EntMemberInfo::select('UserID','MemNumber', 'MemEndTime', 'States')->where('DeleteMark', '1')->where('States', '1')->where('AppKey', $appkey)->where('UserName', $mobile)->first();
        return $entBookInfo;
    }

    /*
     * 微信支付
     * */
    public function wxpay(){
        return view('web/weixin/wxpay');
    }
}

